<!-- 我的测评 -->
<template>
	<view>
		<block v-if="listGood.length>0">
			<view class="body">
				<block v-for="(item,index) in listGood" :key="index">
					<view class="item dis dis2 dis3" @click="result(item.id)">
						<view class="left_1">
							<view class="lsftTop dis dis2">
								<view class="le_1">{{item.timed}}</view>
								<view class="le_2 dis dis5 dis1">
									<text class="le_text1">{{item.timem}}</text>
									<text class="le_text2">{{item.timey}}</text>
								</view>
							</view>
							<view class="lstBOtm dis dis2">{{item.timeh}} 完成体检</view>
						</view>
						<view class="rigth_1 dis dis2">
							<text class="rigthText">查看完整结果</text>
							<image src="../../../static/img/65.png" mode="aspectFit" class="luj"></image>
						</view>
					</view>
				</block>
			</view>
		</block>
		<block v-if="isShow && listGood.length<=0">
			<ques :text1="text1" :text2="text2" :text3="text3"></ques>
		</block>
	</view>
</template>

<script>
	let app = getApp().globalData;
	import util from '../../../common/js/util.js';
	import result from '../../../common/js/indexFx.js';
	import ques from '../../../components/quesheng.vue';
	export default {
		components: {
			ques
		},
		data() {
			return {
				indexTo: -1,
				list: [{
					texts: '上火',
				}, {
					texts: '脱发',
				}, {
					texts: '失眠',
				}, {
					texts: '发胖',
				}, {
					texts: '情绪',
				}, {
					texts: '体质'
				}],
				listIndex: 0,
				goodList: [],
				listGood: [],
				id: 0,
				model: '',
				is: true, //记录是否需要再次请求
				isShow: false,
				text1: '你还没有体检记录',
				text2: '快去体检吧',
				text3: '立刻体检',

			};
		},
		methods: {
			select(e) {
				this.indexTo = e
			},
			getIndex(e) {
				this.listIndex = e
			},
			getData(id) {
				let that = this;
				let ids = that.id; //上一次最后一条记录的id；
				let s = 0; //最新一次的id
				let list = this.listGood;
				this.$http._post('user/examinationhistory.do', {
					id: id
				}).then(res => {
					console.log(res)
					if (res.data.issuccess == 1) {
						let {
							data
						} = res.data;
						let is = true;
						if (data.length <= 0) {
							that.is = false;
							that.isShow = true;
							return
						}
						// console.log(data)
						for (let i = 0; i < data.length; i++) {
							data[i].timey = data[i].time.slice(0, 4); //年
							data[i].timem = `${data[i].time.slice(5,7)}月`; //年
							data[i].timed = data[i].time.slice(8, 10); //年
							data[i].timeh = data[i].time.slice(11, 16);
							if (i == data.length - 1) {
								s = data[i].id
							}
						}
						if (s == ids) {
							that.is = false;
						} else {
							that.id = s;
							if (list.length <= 0) {
								that.listGood = data
							} else {
								list.push.apply(list, data);
								that.listGood = list;
							}
						}
					}
				})
			},

			result(id) {
				app.reportid = id;
				result.everyday(id).then(res => {
					console.log(res)
					if (res.data.issuccess == 1) {
						let {
							data
						} = res.data;
						app.progresstext = data.age
						app.progresstext1 = data.score_zhf
						app.retuData = data;
						if (data.age == -1) {
							app.progresstext = '?'
						}
						if (data.score_zhf == -1) {
							app.progresstext1 = '?'
						}
						let list = data.weidulist;
						let listpo = [];
						let values = [];
						for (let i = 0; i < list.length; i++) {
							let num = (list[i].score).toFixed(0);
							let name = `${list[i].weidu}\n${num}`;

							if (list[i].weidu == '上火' && list[i].isempty == 1) {
								name = `${list[i].weidu}\n？`;
							}
							listpo.push({
								name,
								max: 100
							});
							values.push(list[i].score)
						}
						app.listRadar1 = listpo;
						app.value1 = values;
						uni.navigateTo({
							url: `/second/me/everydayResult/everydayResult`
						})
					}
					// let data = res;
					// app.ensue = data;
					// app.reportid = data.reportid;
					// let daily = 0;
					// if (data.zhibiao == '正常' || data.zhibiao == '') {
					// 	daily = 0
					// } else {
					// 	daily = 1
					// }
					// uni.navigateTo({
					// 	url: `../result/result?daily=${daily}`
					// })
				})

			},
			goUrl() {
				uni.redirectTo({
					url: '../everyday/everyday'
				})
			},

		},
		onLoad(e) {
			this.indexTo = e.index;
			let that = this;
			uni.getSystemInfo({
				success(res) {
					that.model = res.brand;
					console.log('手机牌子', res.brand) //手机牌子
					console.log('手机型号', res.model) //手机型号
				}
			})

			this.getData()
			// this.getListData()
		},
		onReachBottom() {
			// let that = this;
			let is = this.is;
			let id = this.id;
			if (!is) {
				this.$http.isMssage('暂无更多数据')
				return
			}
			this.getData(id)


			console.log('到底了')
		},
	}
</script>

<style lang="scss" scoped>
	@import "../../../common/css/flex.css";
	@import "../../../common/css/index.scss";

	.top {
		width: 750upx;
		height: 96upx;
		background: #FFFFFF;

		.active {
			width: 128upx;
			height: 100%;
			font-size: 32upx;
			font-family: $typeface;
			font-weight: 500;
			color: #999999;
			position: relative;

			.lin {
				width: 48upx;
				height: 8upx;
				position: absolute;
				bottom: 0;
			}

			.select {
				color: #333333;
			}
		}

		.active1 {
			margin-left: 180upx;
			margin-right: 120upx;
		}

		.active2 {
			margin-right: 180upx;
		}
	}

	.items {
		width: 100%;
		height: 120upx;

		.item {
			width: 103upx;
			height: 56upx;
			border-radius: 50upx;
			background-color: #FFFFFF;
			font-size: 28upx;
			font-family: $typeface1;
			font-weight: 400;
			color: #666666;
		}

		.selects {
			background-color: $bgColor;
			color: #333;
			font-family: $typeface;
		}
	}

	.bodys {
		width: 686upx;
		margin: auto;

		.item {
			width: 100%;
			height: 171upx;
			background-image: url(../../../static/image/bg_12.png);
			background-size: 100% 100%;
			border-radius: 10upx;
			margin-bottom: 32upx;

			.itemLeft {
				height: 107upx;
				margin-left: 24upx;

				.text_1 {
					font-size: 36upx;
					font-family: $typeface;
					font-weight: 500;
					color: #333333;
				}

				.text_2 {

					font-size: 24upx;
					font-family: $typeface1;
					font-weight: 400;
					color: #999999;
				}
			}

			.itemRigth {
				height: 39upx;
				margin-right: 25upx;

				.rigthText {
					font-size: 26upx;
					font-family: $typeface;
					font-weight: 500;
					color: #44AEFF;
				}
			}
		}
	}

	.body {
		width: 686upx;
		margin: auto;

		.item {
			width: 100%;
			height: 171upx;
			background-image: url(../../../static/image/bg_12.png);
			background-size: 100% 100%;
			border-radius: 10upx;
			margin-top: 32upx;

			.left_1 {
				height: 145upx;
				margin-left: 24upx;

				.lsftTop {
					height: 112upx;

					.le_1 {
						width: 96upx;
						height: 112upx;
						font-size: 80upx;
						font-family: $typeface;
						font-weight: 500;
						color: #FFAA60;
					}

					.le_2 {
						height: 112upx;
						margin-left: 8upx;

						.le_text1 {
							font-size: 24upx;
							font-family: $typeface1;
							font-weight: 400;
							color: #999999;
						}

						.le_text2 {

							font-size: 24upx;
							font-family: $typeface1;
							font-weight: 400;
							color: #999999;
						}
					}
				}

				.lstBOtm {
					font-size: 24upx;
					font-family: $typeface1;
					font-weight: 400;
					color: #C1C1C1;
				}
			}

			.rigth_1 {
				height: 39upx;
				margin-right: 25upx;

				.rigthText {
					font-size: 26upx;
					font-family: $typeface;
					font-weight: 500;
					color: #44AEFF;

				}

				.luj {
					width: 10upx;
					height: 16upx;
					margin-left: 8upx;
				}
			}
		}
	}
</style>
